var addCaseList = {isDealInfoData: {}, zTreeInstance: null, validateFields: {}};//初始化病历新增对话框
var windowNameIndex = parent.layer.getFrameIndex(window.name); //获取窗口索引
// 清除数据
addCaseList.clearData = function () {
    this.isDealInfoData = {};
};
// 设置对话框中的数据 @param key 数据的名称 @param val 数据的具体值
addCaseList.set = function (key, val) {
    this.isDealInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
    return this;
};
// 设置对话框中的数据 @param key 数据的名称 @param val 数据的具体值
addCaseList.get = function (key) {
    return $("#" + key).val();
};
//关闭此对话框
addCaseList.close = function () {
    parent.layer.close(windowNameIndex);
};
// 有提示的关闭此对话框
addCaseList.closeTips = function () {
    if (confirm("退出编写，是否保存病历?")) {
        addCaseList.saveDraft();
    } else {
        parent.layer.close(windowNameIndex);
    }
};
//收集数据
addCaseList.collectData = function () {
    this.set('id').set('customerId').set('reservationsId').set('zhushu').set('nowMedicalHistory').set('beforeMedicalHistory').set('doctorId').set('nurseId');
    this.set('mouthCheck').set('auxiliaryCheck').set('diagnose').set('remedyPlan').set('dispose').set('doctorAdvice');
    this.set('type').set('lable').set('remarks').set('finnallyTime').set("payServiceId").set("arrivalStatus");
    //1.第一组检查项
    var leftUp1 = [];
    $(".leftUp1").each(function () {
        leftUp1.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['leftUp1'] = leftUp1.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var leftDown1 = [];
    $(".leftDown1").each(function () {
        leftDown1.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['leftDown1'] = leftDown1.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var rightUp1 = [];
    $(".rightUp1").each(function () {
        rightUp1.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['rightUp1'] = rightUp1.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var rightDown1 = [];
    $(".rightDown1").each(function () {
        rightDown1.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['rightDown1'] = rightDown1.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var remarks1 = [];
    $(".remarks1").each(function () {
        remarks1.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['remarks1'] = remarks1.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    //2.第二种检查
    var leftUp2 = [];
    $(".leftUp2").each(function () {
        leftUp2.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['leftUp2'] = leftUp2.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var leftDown2 = [];
    $(".leftDown2").each(function () {
        leftDown2.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['leftDown2'] = leftDown2.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var rightUp2 = [];
    $(".rightUp2").each(function () {
        rightUp2.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['rightUp2'] = rightUp2.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var rightDown2 = [];
    $(".rightDown2").each(function () {
        rightDown2.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['rightDown2'] = rightDown2.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var remarks2 = [];
    $(".remarks2").each(function () {
        remarks2.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['remarks2'] = remarks2.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    //第三组
    var leftUp3 = [];
    $(".leftUp3").each(function () {
        leftUp3.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['leftUp3'] = leftUp3.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var leftDown3 = [];
    $(".leftDown3").each(function () {
        leftDown3.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['leftDown3'] = leftDown3.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var rightUp3 = [];
    $(".rightUp3").each(function () {
        rightUp3.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['rightUp3'] = rightUp3.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var rightDown3 = [];
    $(".rightDown3").each(function () {
        rightDown3.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['rightDown3'] = rightDown3.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var remarks3 = [];
    $(".remarks3").each(function () {
        remarks3.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['remarks3'] = remarks3.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    //第四组
    var leftUp4 = [];
    $(".leftUp4").each(function () {
        leftUp4.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['leftUp4'] = leftUp4.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var leftDown4 = [];
    $(".leftDown4").each(function () {
        leftDown4.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['leftDown4'] = leftDown4.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var rightUp4 = [];
    $(".rightUp4").each(function () {
        rightUp4.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['rightUp4'] = rightUp4.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var rightDown4 = [];
    $(".rightDown4").each(function () {
        rightDown4.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['rightDown4'] = rightDown4.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var remarks4 = [];
    $(".remarks4").each(function () {
        remarks4.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['remarks4'] = remarks4.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    //第五组
    var leftUp5 = [];
    $(".leftUp5").each(function () {
        leftUp5.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['leftUp5'] = leftUp5.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var leftDown5 = [];
    $(".leftDown5").each(function () {
        leftDown5.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['leftDown5'] = leftDown5.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var rightUp5 = [];
    $(".rightUp5").each(function () {
        rightUp5.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['rightUp5'] = rightUp5.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var rightDown5 = [];
    $(".rightDown5").each(function () {
        rightDown5.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['rightDown5'] = rightDown5.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
    var remarks5 = [];
    $(".remarks5").each(function () {
        remarks5.push($(this).val()); //这里的value就是每一个input的value值~
    });
    this.isDealInfoData['remarks5'] = remarks5.join("&&");//把一组检查的所有左上数组通过&&分割拼接成字符串 比如  1&&1
};
//验证数据是否为空
addCaseList.validate = function () {
    $('#isDealInfoForm').data("bootstrapValidator").resetForm();
    $('#isDealInfoForm').bootstrapValidator('validate');
    return $("#isDealInfoForm").data('bootstrapValidator').isValid();
};
//另存为模板
addCaseList.saveTemplate = function () {
    var index = layer.open({
        type: 2,
        title: '病历模板保存',
        area: ['45%', '95%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/doctor_saveTemplate'
    });
    this.layerIndex = index;
};


//提交新增病历
var num = 0;
addCaseList.save = function () {
    if (confirm("确定提交之后不能修改和删除病历")) {
        num++;
        if (num == 1) {
            var id = $("#customerId").val();
            this.clearData();
            this.collectData();
            if (!this.validate()) {
                num = 0;
                return;
            }
            if ($("#doctorId").val() == null || $("#doctorId").val() == "") {
                num =0;
                alert("请选择医生！");
                return;
            }
            this.isDealInfoData["type"] = $("input[name='clinical']:checked").val();
            var ajax = new $ax(Feng.ctxPath + "/doctorLooked/save", function (data) {
                if (confirm("是否去添加随访")) {
                    Feng.success("操作成功!");
                    window.parent.location.href = Feng.ctxPath + '/doctorDetails/doctor_seeDiagnosis/' + id + '/' + 3
                    window.parent.parent.DoctorLooked.search();
                } else {
                    Feng.success("操作成功!");
                    window.parent.location.href = Feng.ctxPath + '/doctorDetails/doctor_seeDiagnosis/' + id + '/' + 1
                    window.parent.parent.DoctorLooked.search();
                }
            }, function () {
                num = 0;
                alert("没有权限，请联系系统管理员！");
                window.parent.location.href = Feng.ctxPath + '/doctorDetails/doctor_seeDiagnosis/' + id + '/' + 1;
            });
            ajax.set(this.isDealInfoData);
            ajax.start();
        }
    }
};
//保存新增病历
var nums = 0;
addCaseList.saveDraft = function () {
    nums++;
    if (nums == 1) {
        var id = $("#customerId").val();
        this.clearData();
        this.collectData();
        if (!this.validate()) {
            nums =0;
            return;
        }
        if ($("#doctorId").val() == null || $("#doctorId").val() == "") {
            nums =0;
            alert("请选择医生！");
            return;
        }
        if ($("#payServiceId").val() == null || $("#payServiceId").val() == "") {
            nums =0;
            alert("请选择就诊项目！");
            return;
        }
        if ($("#arrivalStatus").val() == null || $("#arrivalStatus").val() == "") {
            nums =0;
            alert("请选择就诊状态！");
            return;
        }
        this.isDealInfoData["type"] = $("input[name='clinical']:checked").val();
        var ajax = new $ax(Feng.ctxPath + "/doctorLooked/saveDraft", function (data) {
            var index = layer.open({
                type: 2,
                title: '项目是否结束',
                area: ['30%', '40%'],
                fix: true,
                maxmin: true,
                content: Feng.ctxPath + '/doctorLooked/doctor_statusic/' + data.split(',')[1]+"/"+id
            });
            this.layerIndex = index;
            nums =0;
        }, function () {
            nums =0;
            alert("没有权限，请联系系统管理员！");
            window.parent.location.href = Feng.ctxPath + '/doctorDetails/doctor_seeDiagnosis/' + id + '/' + 1;
        });
        ajax.set(this.isDealInfoData);
        ajax.start();
    }
};
//完成治疗
addCaseList.finshDraft = function () {
    if (confirm("确定完成治疗之后不能修改和删除病历")) {
        var id = $("#customerId").val();
        this.clearData();
        this.collectData();
        if (!this.validate()) {
            return;
        }
        if ($("#doctorId").val() == null || $("#doctorId").val() == "") {
            nums =0;
            alert("请选择医生！");
            return;
        }
        if ($("#payServiceId").val() == null || $("#payServiceId").val() == "") {
            nums =0;
            alert("请选择就诊项目！");
            return;
        }
        if ($("#arrivalStatus").val() == null || $("#arrivalStatus").val() == "") {
            nums =0;
            alert("请选择就诊状态！");
            return;
        }
        this.isDealInfoData["type"] = $("input[name='clinical']:checked").val();
        var ajax = new $ax(Feng.ctxPath + "/doctorLooked/finshDraft", function (data) {
            var index = layer.open({
                type: 2,
                title: '项目是否结束',
                area: ['30%', '40%'],
                fix: true,
                maxmin: true,
                content: Feng.ctxPath + '/doctorLooked/doctor_statusic/' + data.split(',')[1]+"/"+id
            });
            this.layerIndex = index;
            nums =0;
        }, function () {
            nums =0;
            alert("没有权限，请联系系统管理员！");
            window.parent.location.href = Feng.ctxPath + '/doctorDetails/doctor_seeDiagnosis/' + id + '/' + 1;
        });
        ajax.set(this.isDealInfoData);
        ajax.start();
    }
};
// 保存修改病历
var numsup = 0;
addCaseList.update = function () {
    numsup++;
    if (numsup == 1) {
        var id = $("#customerId").val();
        this.clearData();
        this.collectData();
        if (!this.validate()) {
            numsup = 0;
            return;
        }
        if ($("#doctorId").val() == null || $("#doctorId").val() == "") {
            numsup = 0;
            alert("请选择医生！");
            return;
        }
        if ($("#payServiceId").val() == null || $("#payServiceId").val() == "") {
            numsup = 0;
            alert("请选择就诊项目！");
            return;
        }
        if ($("#arrivalStatus").val() == null || $("#arrivalStatus").val() == "") {
            numsup = 0;
            alert("请选择就诊状态！");
            return;
        }
        var caseId=$("#id").val();
        this.isDealInfoData["type"] = $("input[name='clinical']:checked").val();
        var ajax = new $ax(Feng.ctxPath + "/doctorLooked/update_record", function (data) {
            var index = layer.open({
                type: 2,
                title: '项目是否结束',
                area: ['30%', '40%'],
                fix: true,
                maxmin: true,
                content: Feng.ctxPath + '/doctorLooked/doctor_statusic/' + caseId+"/"+id
            });
            this.layerIndex = index;
            numsup = 0;
        }, function () {
            numsup = 0;
            alert("没有权限，请联系系统管理员！");
            window.parent.location.href = Feng.ctxPath + '/doctorDetails/doctor_seeDiagnosis/' + id + '/' + 1;
        });
        ajax.set(this.isDealInfoData);
        ajax.start();
    }
};
// 提交修改病历
addCaseList.updates = function () {
    if (confirm("确定提交之后不能修改和删除病历")) {
        var id = $("#customerId").val();
        this.clearData();
        this.collectData();
        if (!this.validate()) {
            return;
        }
        this.isDealInfoData["type"] = $("input[name='clinical']:checked").val();
        var ajax = new $ax(Feng.ctxPath + "/doctorLooked/update_records", function (data) {
            if (confirm("是否去添加随访")) {
                Feng.success("操作成功!");
                window.parent.location.href = Feng.ctxPath + '/doctorDetails/doctor_seeDiagnosis/' + id + '/' + 3
                window.parent.parent.DoctorLooked.search();
            } else {
                Feng.success("操作成功!");
                window.parent.location.href = Feng.ctxPath + '/doctorDetails/doctor_seeDiagnosis/' + id + '/' + 1
                window.parent.parent.DoctorLooked.search();
            }
        }, function () {
            alert("没有权限，请联系系统管理员！");
            window.parent.location.href = Feng.ctxPath + '/doctorDetails/doctor_seeDiagnosis/' + id + '/' + 1;
        });
        ajax.set(this.isDealInfoData);
        ajax.start();
    }
};
// 提交修改病历
addCaseList.updateFinsh = function () {
    if (confirm("完成治疗提交之后不能修改和删除病历")) {
        var id = $("#customerId").val();
        this.clearData();
        this.collectData();
        if (!this.validate()) {
            return;
        }
        if ($("#doctorId").val() == null || $("#doctorId").val() == "") {
            nums =0;
            alert("请选择医生！");
            return;
        }
        if ($("#payServiceId").val() == null || $("#payServiceId").val() == "") {
            nums =0;
            alert("请选择就诊项目！");
            return;
        }
        if ($("#arrivalStatus").val() == null || $("#arrivalStatus").val() == "") {
            nums =0;
            alert("请选择就诊状态！");
            return;
        }
        var caseId=$("#id").val();
        this.isDealInfoData["type"] = $("input[name='clinical']:checked").val();
        var ajax = new $ax(Feng.ctxPath + "/doctorLooked/update_finsh", function (data) {
            var index = layer.open({
                type: 2,
                title: '项目是否结束',
                area: ['30%', '40%'],
                fix: true,
                maxmin: true,
                content: Feng.ctxPath + '/doctorLooked/doctor_statusic/' + caseId+"/"+id
            });
            this.layerIndex = index;
            nums =0;
        }, function () {
            nums =0;
            alert("没有权限，请联系系统管理员！");
            window.parent.location.href = Feng.ctxPath + '/doctorDetails/doctor_seeDiagnosis/' + id + '/' + 1;
        });
        ajax.set(this.isDealInfoData);
        ajax.start();
    }
};
//病历模板
addCaseList.template = function () {
    var val = $('input[name="clinical"]:checked').val();
    var index = layer.open({
        type: 2,
        title: '病历模板',
        area: ['50%', '90%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/doctor_template/' + val
    });
    this.layerIndex = index;
};
//病历模板层级
addCaseList.addOblog = function () {
    var index = layer.open({
        type: 2,
        title: '病历模板层级',
        area: ['40%', '40%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/doctor_oblog'
    });
    this.layerIndex = index;
};

$(function () {
    Feng.initValidator("isDealInfoForm", addCaseList.validateFields);
    $(".textareaPosition,.inputOption").on('click', 'textarea', function (e) {
        e.stopPropagation();
        $(".contentBox").hide();
        $(this).siblings().show();
    });
    $(document).click(function () {
        $(".contentBox").hide()
    });
    $(document).on('mouseleave', '.contentBox', function () {
        $(".contentBox").hide()
    });
    $(".textareaPosition,.inputOption").on('click', '.contentBox', function (e) {
        e.stopPropagation();
    });
    $(".inputOption span").click(function () {
        var text = $(this).text();
        var scr = $(this).parents('.contentBox').siblings().val();
        var num = $(this).parents('.contentBox').siblings().get(0).selectionStart;
        var lastInput = scr.substring(0, num) + text + scr.substring(num, scr.length);
        $(this).parents('.contentBox').siblings().val(lastInput);
        $(this).parents('.contentBox').siblings().get(0).selectionStart = num + $(this).text().length;
    });
    $(".textareaPosition").on('click', '.contentBox span', function () {
        var text = $(this).text();
        var scr = $(this).parents('.contentBox').siblings().val();
        var num = $(this).parents('.contentBox').siblings().get(0).selectionStart;
        var lastInput = scr.substring(0, num) + text + scr.substring(num, scr.length);
        $(this).parents('.contentBox').siblings().val(lastInput);
        $(this).parents('.contentBox').siblings().get(0).selectionStart = num + $(this).text().length;
    });
    $(".addTooth").click(function () {
        var Box = $(this).parent().prev().clone();
        Box.find('textarea').val("");
        Box.find('input').val("");
        $(this).parent().before(Box)
    });
    $(".textareaPosition").on('click', '.deleteBtn', function () {
        var index = $(this).parents('.textareaContent').index();
        if (index != 1) {
            $(this).parents('.textareaContent').remove();
        }
    });
    $("#new_clinical").click(function () {
        $('.single').show();
        $(".revisit").text("主述");
    });
    $("#old_clinical").click(function () {
        $('.single').hide();
        $(".revisit").text("复诊");
    });
    if ($("#doctorId").val() != "") {
        // $("#doctorId").attr('disabled', true);
    }
    var index;
    $(".textareaPosition").on('click', '.toothPosition', function (e) {
        e.stopPropagation();
        $(".toothPosition").removeClass('tips');
        $(this).addClass('tips');
        var leftUpNum = $(this).find('.leftUp').val();
        var rightUpNum = $(this).find('.rightUp').val();
        var leftDownNum = $(this).find('.leftDown').val();
        var rightDownNum = $(this).find('.rightDown').val();
        index = layer.open({
            type: 4,
            tips: [1, '#ffffff'],
            closeBtn: 0,
            area: ['auto', 'auto'],
            content: ['<div>' + $("#noneBox").html() + '</div>', '.tips'],
            success: function (layero, index) {
                $("#fullNu,#halfUpperNu,#halfLowerNu").hide();
                $("#fullHen,#halfUpperHen,#halfLowerHen").show();
                if (leftUpNum.length > 0) {
                    for (var w = 0; w < $(layero).find('.toothTopLeft>span').length; w++) {
                        for (var i = 0; i < leftUpNum.length; i++) {
                            if ($(layero).find('.toothTopLeft>span').eq(w).find('span').text() == leftUpNum.substring(i, i + 1)) {
                                $(layero).find('.toothTopLeft>span').eq(w).find('span').addClass('spanStyle');
                            }
                        }
                    }
                }
                if (rightUpNum.length > 0) {
                    for (var w = 0; w < $(layero).find('.toothTopRight>span').length; w++) {
                        for (var i = 0; i < rightUpNum.length; i++) {
                            if ($(layero).find('.toothTopRight>span').eq(w).find('span').text() == rightUpNum.substring(i, i + 1)) {
                                $(layero).find('.toothTopRight>span').eq(w).find('span').addClass('spanStyle');
                            }
                        }
                    }
                }
                if (leftDownNum.length > 0) {
                    for (var w = 0; w < $(layero).find('.toothBottomLeft>span').length; w++) {
                        for (var i = 0; i < leftDownNum.length; i++) {
                            if ($(layero).find('.toothBottomLeft>span').eq(w).find('span').text() == leftDownNum.substring(i, i + 1)) {
                                $(layero).find('.toothBottomLeft>span').eq(w).find('span').addClass('spanStyle');
                            }
                        }
                    }
                }
                if (rightDownNum.length > 0) {
                    for (var w = 0; w < $(layero).find('.toothBottomRight>span').length; w++) {
                        for (var i = 0; i < rightDownNum.length; i++) {
                            if ($(layero).find('.toothBottomRight>span').eq(w).find('span').text() == rightDownNum.substring(i, i + 1)) {
                                $(layero).find('.toothBottomRight>span').eq(w).find('span').addClass('spanStyle');
                            }
                        }
                    }
                }
            }
        });
    });
    $(document).click(function () {
        layer.close(index)
    });
    $(document).on('mouseleave', '#tipsBox', function () {
        layer.close(index)
    });
    $(document).on('click', '.tipsUl>li', function (e) {
        e.stopPropagation();
        $(this).addClass('tipsLi').siblings().removeClass('tipsLi');
        if ($(this).index() == 0) {
            $(this).parent().siblings().children('#permanent').show().siblings().hide();
            $("#fullNu,#halfUpperNu,#halfLowerNu").hide();
            $("#fullHen,#halfUpperHen,#halfLowerHen").show();
        } else if ($(this).index() == 1) {
            $(this).parent().siblings().children('#deciduous').show().siblings().hide();
            $("#fullHen,#halfUpperHen,#halfLowerHen").hide();
            $("#fullNu,#halfUpperNu,#halfLowerNu").show();
        }
    });
    $(document).on('click', '#emptyFull', function (e) {
        e.stopPropagation();
        $("#permanent span").removeClass('spanStyle');
        $("#deciduous span").removeClass('spanStyle');
        if ($('#synchronization').is(':checked')) {
            $(".toothPosition>input").val("");
        } else {
            $(".tips>input").val("");
        }
    });
    $(document).on('click', '#fullHen', function (e) {
        e.stopPropagation();
        $("#permanent span").addClass('spanStyle');
        $("#deciduous span").removeClass('spanStyle');
        if ($('#synchronization').is(':checked')) {
            $(".toothPosition>.leftUp").val("87654321");
            $(".toothPosition>.rightUp").val("12345678");
            $(".toothPosition>.leftDown").val("87654321");
            $(".toothPosition>.rightDown").val("12345678");
        } else {
            $(".tips>.leftUp").val("87654321");
            $(".tips>.rightUp").val("12345678");
            $(".tips>.leftDown").val("87654321");
            $(".tips>.rightDown").val("12345678");
        }
    });
    $(document).on('click', '#halfUpperHen', function (e) {
        e.stopPropagation();
        $("#permanent .toothTop span").addClass('spanStyle');
        $("#deciduous .toothTop span").removeClass('spanStyle');
        if ($('#synchronization').is(':checked')) {
            $(".toothPosition>.leftUp").val("87654321");
            $(".toothPosition>.rightUp").val("12345678");
        } else {
            $(".tips>.leftUp").val("87654321");
            $(".tips>.rightUp").val("12345678");
        }
    });
    $(document).on('click', '#halfLowerHen', function (e) {
        e.stopPropagation();
        $("#permanent .toothBottom span").addClass('spanStyle');
        $("#deciduous .toothBottom span").removeClass('spanStyle');
        if ($('#synchronization').is(':checked')) {
            $(".toothPosition>.leftDown").val("87654321");
            $(".toothPosition>.rightDown").val("12345678");
        } else {
            $(".tips>.leftDown").val("87654321");
            $(".tips>.rightDown").val("12345678");
        }
    });
    $(document).on('click', '#fullNu', function (e) {
        e.stopPropagation();
        $("#deciduous span").addClass('spanStyle');
        $("#permanent span").removeClass('spanStyle');
        if ($('#synchronization').is(':checked')) {
            $(".toothPosition>.leftUp").val("EDCBA");
            $(".toothPosition>.rightUp").val("ABCDE");
            $(".toothPosition>.leftDown").val("EDCBA");
            $(".toothPosition>.rightDown").val("ABCDE");
        } else {
            $(".tips>.leftUp").val("EDCBA");
            $(".tips>.rightUp").val("ABCDE");
            $(".tips>.leftDown").val("EDCBA");
            $(".tips>.rightDown").val("ABCDE");
        }
    });
    $(document).on('click', '#halfUpperNu', function (e) {
        e.stopPropagation();
        $("#deciduous .toothTop span").addClass('spanStyle');
        $("#permanent .toothTop span").removeClass('spanStyle');
        if ($('#synchronization').is(':checked')) {
            $(".toothPosition>.leftUp").val("EDCBA");
            $(".toothPosition>.rightUp").val("ABCDE");
        } else {
            $(".tips>.leftUp").val("EDCBA");
            $(".tips>.rightUp").val("ABCDE");
        }
    });
    $(document).on('click', '#halfLowerNu', function (e) {
        e.stopPropagation();
        $("#deciduous .toothBottom span").addClass('spanStyle');
        $("#permanent .toothBottom span").removeClass('spanStyle');
        if ($('#synchronization').is(':checked')) {
            $(".toothPosition>.leftDown").val("EDCBA");
            $(".toothPosition>.rightDown").val("ABCDE");
        } else {
            $(".tips>.leftDown").val("EDCBA");
            $(".tips>.rightDown").val("ABCDE");
        }
    });
    $(document).on('click', '.toothTopLeft>span', function (e) {
        e.stopPropagation();
        var arr = [];
        var text = $(this).text();
        if ($(this).children().attr('class') == 'spanStyle') {
            var inputValue = $(".tips>.leftUp").val().replace(text, "");
            for (var i = 0; i < inputValue.length; i++) {
                arr.push(inputValue.substring(i, i + 1));
            }
            for (var i = arr.length - 1; i >= 0; i--) {
                for (var j = 0; j < i; j++) {
                    if (arr[j + 1] > arr[j]) {
                        var change = arr[j + 1];
                        arr[j + 1] = arr[j];
                        arr[j] = change
                    }
                }
            };
            var str = "";
            for (var i = 0; i < arr.length; i++) {
                str += arr[i]
            }
            if ($('#synchronization').is(':checked')) {
                $(".toothPosition>.leftUp").val(str);
            } else {
                $(".tips>.leftUp").val(str);
            }
            $(this).children().removeClass('spanStyle');
        } else {
            var add = $(".tips>.leftUp").val() + text;
            for (var d = 0; d < add.length; d++) {
                arr.push(add.substring(d, d + 1));
            }
            for (var i = arr.length - 1; i >= 0; i--) {
                for (var j = 0; j < i; j++) {
                    if (arr[j + 1] > arr[j]) {
                        var change = arr[j + 1];
                        arr[j + 1] = arr[j];
                        arr[j] = change
                    }
                }
            };
            var str = "";
            for (var i = 0; i < arr.length; i++) {
                str += arr[i]
            }
            $(this).children().addClass('spanStyle');
            if ($('#synchronization').is(':checked')) {
                $(".toothPosition>.leftUp").val(str);
            } else {
                $(".tips>.leftUp").val(str);
            }
        }
    });
    $(document).on('click', '.toothTopRight>span', function (e) {
        e.stopPropagation();
        var arr = [];
        var text = $(this).text();
        if ($(this).children().attr('class') == 'spanStyle') {
            var inputValue = $(".tips>.rightUp").val().replace(text, "");
            for (var i = 0; i < inputValue.length; i++) {
                arr.push(inputValue.substring(i, i + 1));
            }
            for (var i = arr.length - 1; i >= 0; i--) {
                for (var j = 0; j < i; j++) {
                    if (arr[j + 1] < arr[j]) {
                        var change = arr[j + 1];
                        arr[j + 1] = arr[j];
                        arr[j] = change
                    }
                }
            };
            var str = "";
            for (var i = 0; i < arr.length; i++) {
                str += arr[i]
            }
            if ($('#synchronization').is(':checked')) {
                $(".toothPosition>.rightUp").val(str);
            } else {
                $(".tips>.rightUp").val(str);
            }
            $(this).children().removeClass('spanStyle');
        } else {
            $(this).children().addClass('spanStyle');
            var add = $(".tips>.rightUp").val() + text;
            for (var d = 0; d < add.length; d++) {
                arr.push(add.substring(d, d + 1));
            }
            for (var i = arr.length - 1; i >= 0; i--) {
                for (var j = 0; j < i; j++) {
                    if (arr[j + 1] < arr[j]) {
                        var change = arr[j + 1];
                        arr[j + 1] = arr[j];
                        arr[j] = change
                    }
                }
            };
            var str = "";
            for (var i = 0; i < arr.length; i++) {
                str += arr[i]
            }
            if ($('#synchronization').is(':checked')) {
                $(".toothPosition>.rightUp").val(str);
            } else {
                $(".tips>.rightUp").val(str);
            }
        }
    });
    $(document).on('click', '.toothBottomLeft>span', function (e) {
        e.stopPropagation();
        var arr = [];
        var text = $(this).text();
        if ($(this).children().attr('class') == 'spanStyle') {
            var inputValue = $(".tips>.leftDown").val().replace(text, "");
            for (var i = 0; i < inputValue.length; i++) {
                arr.push(inputValue.substring(i, i + 1));
            }
            for (var i = arr.length - 1; i >= 0; i--) {
                for (var j = 0; j < i; j++) {
                    if (arr[j + 1] > arr[j]) {
                        var change = arr[j + 1];
                        arr[j + 1] = arr[j];
                        arr[j] = change
                    }
                }
            };
            var str = "";
            for (var i = 0; i < arr.length; i++) {
                str += arr[i]
            }
            if ($('#synchronization').is(':checked')) {
                $(".toothPosition>.leftDown").val(str);
            } else {
                $(".tips>.leftDown").val(str);
            }
            $(this).children().removeClass('spanStyle');
        } else {
            $(this).children().addClass('spanStyle');
            var add = $(".tips>.leftDown").val() + text;
            for (var d = 0; d < add.length; d++) {
                arr.push(add.substring(d, d + 1));
            }
            for (var i = arr.length - 1; i >= 0; i--) {
                for (var j = 0; j < i; j++) {
                    if (arr[j + 1] > arr[j]) {
                        var change = arr[j + 1];
                        arr[j + 1] = arr[j];
                        arr[j] = change
                    }
                }
            };
            var str = "";
            for (var i = 0; i < arr.length; i++) {
                str += arr[i]
            }
            if ($('#synchronization').is(':checked')) {
                $(".toothPosition>.leftDown").val(str);
            } else {
                $(".tips>.leftDown").val(str);
            }
        }
    });
    $(document).on('click', '.toothBottomRight>span', function (e) {
        e.stopPropagation();
        var arr = [];
        var text = $(this).text();
        if ($(this).children().attr('class') == 'spanStyle') {
            var inputValue = $(".tips>.rightDown").val().replace(text, "");
            for (var i = 0; i < inputValue.length; i++) {
                arr.push(inputValue.substring(i, i + 1));
            }
            for (var i = arr.length - 1; i >= 0; i--) {
                for (var j = 0; j < i; j++) {
                    if (arr[j + 1] < arr[j]) {
                        var change = arr[j + 1];
                        arr[j + 1] = arr[j];
                        arr[j] = change
                    }
                }
            }
            var str = "";
            for (var i = 0; i < arr.length; i++) {
                str += arr[i]
            }
            if ($('#synchronization').is(':checked')) {
                $(".toothPosition>.rightDown").val(str);
            } else {
                $(".tips>.rightDown").val(str);
            }
            $(this).children().removeClass('spanStyle');
        } else {
            $(this).children().addClass('spanStyle');
            var add = $(".tips>.rightDown").val() + text;
            for (var d = 0; d < add.length; d++) {
                arr.push(add.substring(d, d + 1));
            }
            for (var i = arr.length - 1; i >= 0; i--) {
                for (var j = 0; j < i; j++) {
                    if (arr[j + 1] < arr[j]) {
                        var change = arr[j + 1];
                        arr[j + 1] = arr[j];
                        arr[j] = change
                    }
                }
            }
            var str = "";
            for (var i = 0; i < arr.length; i++) {
                str += arr[i]
            }
            if ($('#synchronization').is(':checked')) {
                $(".toothPosition>.rightDown").val(str);
            } else {
                $(".tips>.rightDown").val(str);
            }
        }
    });
    $(".textareaPosition,.inputOption").on('focus', 'textarea', function (e) {
        e.stopPropagation();
        $(".contentBox").hide();
        $(this).siblings().show();
    });
    // $("#check").click(function () {
    //     var reservationsId = $("#reservationsId").val();
    //     var customerId = $("#customerId").val();
    //     var doctor = $("#userName").val();
    //     var cri = reservationsId + "," + customerId+","+doctor;
    //    if($("#check").is(':checked')){
    //        var index = layer.open({
    //            type: 2,
    //            title: '选择项目',
    //            area: ['40%', '40%'], //宽高
    //            fix: true, //不固定
    //            maxmin: true,
    //            content: Feng.ctxPath + '/doctorLooked/doctor_payName/'+ cri
    //        });
    //        this.layerIndex = index;
    //    }
    // })
});